﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace FksAutoTask
{
    public partial class frm_edit : Form
    {
        public string TaskId;

        public frm_edit()
        {
            InitializeComponent();
        }

        private void btn_Modify_Click(object sender, EventArgs e)
        {
            Fks.DataBase.SqlObject sqlobject = new Fks.DataBase.SqlObject();
            string SQL_Update = "update task set name='{0}',email='{1}'  where id='{2}'";
            SQL_Update = string.Format(SQL_Update, this.txt_name.Text, this.txt_email.Text, TaskId);
            if (sqlobject.Exec(SQL_Update) > 0)
            {
                //刷新父窗口的列表
                frm_main fm = (frm_main)this.Owner;
                fm.Dbind();

                this.Hide();
            }
            else
                MessageBox.Show("系统错误！", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }

        private void frm_edit_Load(object sender, EventArgs e)
        {
            Fks.DataBase.SqlObject sqlobject = new Fks.DataBase.SqlObject();
            string SQL_Select = "select * from task where id='" + TaskId + "'";
            DataSet myds = sqlobject.GetDataSet(SQL_Select);

            if (myds != null && myds.Tables.Count > 0 && myds.Tables[0] != null && myds.Tables[0].Rows.Count > 0)
            {
                this.txt_result.Text = myds.Tables[0].Rows[0]["result"].ToString();

                this.lab_group_id.Text = myds.Tables[0].Rows[0]["group_id"].ToString();
                this.txt_name.Text = myds.Tables[0].Rows[0]["name"].ToString();
                this.txt_email.Text = myds.Tables[0].Rows[0]["email"].ToString(); 

            }
        }
    }
}
